package cn.hfatec.shms.web.amb.ykBmyj.action;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.Arrays;
import javax.annotation.Resource;


import cn.hfatec.JsonResponse;
import cn.hfatec.Page;
import cn.hfatec.Table;
import cn.hfatec.constants.SysContant;
import cn.hfatec.freemarker.FreeMarkerUtil;
import cn.hfatec.shms.web.amb.ykBmyj.model.YkBmyjParams;
import cn.hfatec.shms.web.amb.ykBmyj.model.YkBmyj;
import cn.hfatec.shms.web.amb.ykBmyj.service.YkBmyjService;
import cn.hfatec.shms.base.ShmsBaseAction;
import org.springframework.ui.Model;
import javax.validation.Valid;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;



/**
 *
 * @author hfatec codegen
 * @version 1.0
 *
 * the JAVA code is generate by middlegen
 *
 */
@Controller
@RequestMapping("/amb/ykBmyj")
public class YkBmyjAction extends ShmsBaseAction {

    //服务层
    @Resource(name = "YkBmyjService")
    private YkBmyjService ykBmyjService;


    /**
     *
     * 查询列表
     *
     */
    @RequestMapping("/list")
    public String list(YkBmyjParams ykBmyjParams, Model model) {

        List table = ykBmyjService.queryYkBmyjTable(ykBmyjParams);
        model.addAttribute("ykBmyjsTable", table);
        model.addAttribute("ykBmyjParams", ykBmyjParams);
        return "/amb/ykBmyj/list";
    }

    /**
     *
     * 异步查询列表
     *
     */
    @RequestMapping("/ajaxList")
    @ResponseBody
    public String ajaxList(YkBmyjParams ykBmyjParams, Model model) {
        try {
            list(ykBmyjParams, model);
            return new JsonResponse<Map>(JsonResponse.RETURN_SUCCESS, "", FreeMarkerUtil.render("/amb/ykBmyj/table", model)).toString();
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
        return JsonResponse.error;
    }


}
